package com.openlogic.datasource.api.enums;

/**
* @ClassName: SqlParamType
* @Description: sql参数数据类型
* @author weiyongpeng
* @date 2024年11月9日 下午2:57:39
 */
public enum SqlParamType {

    STRING("string","1"),
    INTEGER("integer","2"),
    DATE("date","3"),
    DECIMAL("decimal","4"),
    BOOLEAN("boolean","5");

    private final String key;
    
    private final String value;

    SqlParamType(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }
    
    public String getValue() {
		return value;
	}

	public static SqlParamType getType(String key) {
        for (SqlParamType type : SqlParamType.values()) {
            if (type.key.equals(key)) {
                return type;
            }
        }
        return STRING;
    }
	
	public static SqlParamType getTypeByValue(String value) {
        for (SqlParamType type : SqlParamType.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return STRING;
    }
}
